package com.easy.goods.controller;

import com.easy.common.bean.Goods;
import com.easy.common.service.IGoodsService;
import com.easy.common.util.Result;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @DubboReference
    IGoodsService goodsService;
   @GetMapping("/getAll")
 public Result getAll(Goods goods){
       return Result.success(goodsService.getAll(goods));
   }
   @GetMapping("/select")
 public Result select(Integer id){
       return Result.success(goodsService.getGoodsById(id));
   }
   @PostMapping("/add")
    public Result add(Goods goods){
       return Result.success(goodsService.addGoods(goods));
   }
   @PutMapping("/update")
    public Result update(Goods goods){
       return Result.success(goodsService.updateGoods(goods));
   }
   @DeleteMapping("/delete")
    public Result delete(Integer id){
       return Result.success(goodsService.deleteGoods(id));
   }


}

